package com.imu.purse.mq.produce;

import com.alibaba.fastjson.JSON;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.support.CorrelationData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.imu.purse.modules.app.entity.ImuUserEntity;
import com.imu.purse.mq.bean.TransBean;
import com.imu.purse.mq.config.RabbitUtil;

import java.io.File;
import java.util.UUID;

@Component
public class BitcoinProduce {
	
	
	private static final String exchangeName = RabbitUtil.getValue("queue.bitcoin.exchange");
	
	private String bitKey = RabbitUtil.getValue("queue.bitcoin.key");

	private static final CorrelationData correlationData = new CorrelationData();
	@Autowired
	private RabbitTemplate rabbitTemplate;
	
	/**
	 * 发送消息到消息队列中
	 * @param bean
	 */
	public void sendData(TransBean bean){
		correlationData.setId(bean.getTransId());
		rabbitTemplate.convertAndSend(exchangeName, bitKey, JSON.toJSONString(bean),correlationData);
	}
	
}
